package com.direct.ssh.web.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.direct.ssh.domain.Power;
import com.direct.ssh.domain.Role;
import com.direct.ssh.service.RoleService;

@Component("roleAction")
@Scope(value="prototype")
public class RoleAction extends BaseAction {
	private RoleService roleService;
	private Role role =  new Role();
	private List<Role> roles ;
	private Power power;
	//查询所有的role
	public String queryList(){
		roles = roleService.queryList();
		return "list";
	}
	//通过id查询一个role
	public String querySingle(){
		role = roleService.querySingel(role);
		return "update";
	}
	//删除一个角色
	public String delete (){
		roleService.deleteRole(role);
		return "delete";
	}
	//从角色中删除一个权限
	public String deletePower(){
		roleService.deletePowerFromRole(role,power);
		return querySingle();
	}
	
	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	public Power getPower() {
		return power;
	}
	public void setPower(Power power) {
		this.power = power;
	}
}
